<?php


class SectionTable extends Doctrine_Table {
    public static function getInstance(){
        return Doctrine_Core::getTable('Section');
    }

	# experimental
	public function __construct($name, Doctrine_Connection $conn, $initDefinition = false){
		$this->setAttribute(Doctrine_Core::ATTR_QUERY_CLASS, str_replace("Table", "Query", get_class($this)));
		return parent::__construct($name, $conn, $initDefinition);
	}


	public function createQueryCommons($alias = ''){
		$q=$this->createQuery($alias);
		$q=$this->getSortedQuery("ASC", $q); // visiem querijiem pa virsu jāliek sortable no Sortable pulgina
		return $q;
	}

    public function createQueryForBackend($alias = ''){
    	$q=$this->createQueryCommons($alias);
    	return $q;
    }

    public function createQueryForFrontend($alias=""){
		$q=$this->createQueryCommons($alias);
		$q->addWherePublished();
		return $q;
    }


    public function retrieveListForBackend(){
    	return $this->createQueryForBackend()->execute();
    }

}